package model

import (
	"gorm.io/gorm"
	"service/basic/config"
	"time"
)

type User struct {
	Id        uint           `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;" json:"id"`
	Mobile    string         `gorm:"column:mobile;type:varchar(255);comment:手机号;not null;" json:"mobile"`                     // 手机号
	Password  string         `gorm:"column:password;type:varchar(255);comment:密码;not null;" json:"password"`                   // 密码
	Status    uint           `gorm:"column:status;type:int UNSIGNED;comment:状态:1正常 2冻结;not null;default:1;" json:"status"` // 状态:1正常 2冻结
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (u *User) TableName() string {
	return "user"
}

func (u *User) GetUserId() error {
	return config.DB.Where("id = ?", u.Id).First(&u).Error
}
